Imports NetworkWhiteboard.Regioning
Imports System.Drawing.Printing
Imports Microsoft.Ink
Imports UTE.Serializer
Imports System.Net
Imports System.Net.Sockets
Imports System.Threading


Imports UTE.Graphics

Public Class frmMain
    Inherits System.Windows.Forms.Form

    '****************************
    '****************************
    Const Version As String = "1.0"
    '****************************
    '****************************
    Dim c As frmDrawing = Me.ActiveMdiChild
    Private IconMenuPic As Control
    Private th As Thread
    'Private Freeform As Boolean = True
    Dim mMove As New MouseMove
    Const IconSpace As Integer = 10



    Private Enum PaperType
        Plain
        SmallGraph
        MediumGraph
        LargeGraph
        Zone2Vert
        Zone2Horz
        Zone3
        Zone4
        Zone4Pyr
        Custom
    End Enum

    Private Enum IconType
        Router
        L3Switch
        DBServer
        DirServer
        Firewall
        Hub
        IDS
        Laptop
        MailServer
        MAU
        PC
        Server
        Switch
        Tablet
        Text
        User
        VPN
        WAP
        WebServer
        Custom
    End Enum

    Private Enum ToolBarTypes
        Network
        Computer
    End Enum

    Private Declare Auto Function BitBlt Lib "gdi32.dll" (ByVal _
   hdcDest As IntPtr, ByVal nXDest As Integer, ByVal _
   nYDest As Integer, ByVal nWidth As Integer, ByVal _
   nHeight As Integer, ByVal hdcSrc As IntPtr, ByVal nXSrc _
   As Integer, ByVal nYSrc As Integer, ByVal dwRop As _
   System.Int32) As Boolean

   

    Private Const SRCCOPY As Integer = &HCC0020
#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    Friend WithEvents InkBox2 As Microsoft.Ink.InkPicture
    Friend WithEvents MenuItem23 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem24 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem25 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem26 As System.Windows.Forms.MenuItem
    Friend WithEvents InkMenu As System.Windows.Forms.ContextMenu
    Friend WithEvents MenuItem19 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem36 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem42 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem52 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem54 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem56 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem62 As System.Windows.Forms.MenuItem
    Friend WithEvents RTR1 As System.Windows.Forms.MenuItem
    Friend WithEvents IDS1 As System.Windows.Forms.MenuItem
    Friend WithEvents FW1 As System.Windows.Forms.MenuItem
    Friend WithEvents HB1 As System.Windows.Forms.MenuItem
    Friend WithEvents SW1 As System.Windows.Forms.MenuItem
    Friend WithEvents WAP1 As System.Windows.Forms.MenuItem
    Friend WithEvents SV1 As System.Windows.Forms.MenuItem
    Friend WithEvents LP1 As System.Windows.Forms.MenuItem
    Friend WithEvents TB1 As System.Windows.Forms.MenuItem
    Friend WithEvents PC1 As System.Windows.Forms.MenuItem
    Friend WithEvents USR1 As System.Windows.Forms.MenuItem
    Friend WithEvents RTR2 As System.Windows.Forms.MenuItem
    Friend WithEvents IDS2 As System.Windows.Forms.MenuItem
    Friend WithEvents FW2 As System.Windows.Forms.MenuItem
    Friend WithEvents HB2 As System.Windows.Forms.MenuItem
    Friend WithEvents SW2 As System.Windows.Forms.MenuItem
    Friend WithEvents WAP2 As System.Windows.Forms.MenuItem
    Friend WithEvents SV2 As System.Windows.Forms.MenuItem
    Friend WithEvents LP2 As System.Windows.Forms.MenuItem
    Friend WithEvents TB2 As System.Windows.Forms.MenuItem
    Friend WithEvents PC2 As System.Windows.Forms.MenuItem
    Friend WithEvents USR2 As System.Windows.Forms.MenuItem
    Friend WithEvents SaveFileDialog1 As System.Windows.Forms.SaveFileDialog
    Friend WithEvents MSRV2 As System.Windows.Forms.MenuItem
    Friend WithEvents DSRV2 As System.Windows.Forms.MenuItem
    Friend WithEvents BSRV2 As System.Windows.Forms.MenuItem
    Friend WithEvents WSRV2 As System.Windows.Forms.MenuItem
    Friend WithEvents MAU2 As System.Windows.Forms.MenuItem
    Friend WithEvents VPN2 As System.Windows.Forms.MenuItem
    Friend WithEvents L32 As System.Windows.Forms.MenuItem
    Friend WithEvents L31 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem9 As System.Windows.Forms.MenuItem
    Friend WithEvents VPN1 As System.Windows.Forms.MenuItem
    Friend WithEvents MAU1 As System.Windows.Forms.MenuItem
    Friend WithEvents MSRV1 As System.Windows.Forms.MenuItem
    Friend WithEvents DSRV1 As System.Windows.Forms.MenuItem
    Friend WithEvents BSRV1 As System.Windows.Forms.MenuItem
    Friend WithEvents WSRV1 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem17 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem48 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem51 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem58 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem61 As System.Windows.Forms.MenuItem
    Friend WithEvents OpenFileDialog1 As System.Windows.Forms.OpenFileDialog
    Friend WithEvents LoadPaper As System.Windows.Forms.MenuItem
    Friend WithEvents PlainPaper As System.Windows.Forms.MenuItem
    Friend WithEvents SGraphPaper As System.Windows.Forms.MenuItem
    Friend WithEvents MGraphPaper As System.Windows.Forms.MenuItem
    Friend WithEvents LGraphPaper As System.Windows.Forms.MenuItem
    Friend WithEvents Z2VPaper As System.Windows.Forms.MenuItem
    Friend WithEvents Z2HPaper As System.Windows.Forms.MenuItem
    Friend WithEvents Z3Paper As System.Windows.Forms.MenuItem
    Friend WithEvents Z4Paper As System.Windows.Forms.MenuItem
    Friend WithEvents Z4PPaper As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem15 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem37 As System.Windows.Forms.MenuItem
    Friend WithEvents LN As System.Windows.Forms.MenuItem
    Friend WithEvents FF As System.Windows.Forms.MenuItem
    Friend WithEvents LN1 As System.Windows.Forms.MenuItem
    Friend WithEvents FF1 As System.Windows.Forms.MenuItem
    Friend WithEvents OSD As System.Windows.Forms.OpenFileDialog
    Friend WithEvents SSD As System.Windows.Forms.SaveFileDialog
    Friend WithEvents MenuItem69 As System.Windows.Forms.MenuItem
    Friend WithEvents MenuItem70 As System.Windows.Forms.MenuItem
    Friend WithEvents PrintDocument1 As System.Drawing.Printing.PrintDocument
    Friend WithEvents mnuSaveImage As System.Windows.Forms.MenuItem
    Friend WithEvents mnuSave As System.Windows.Forms.MenuItem
    Friend WithEvents mnuNew As System.Windows.Forms.MenuItem
    Friend WithEvents mnuOpen As System.Windows.Forms.MenuItem
    Friend WithEvents mnuPrintPreview As System.Windows.Forms.MenuItem
    Friend WithEvents mnuPrint As System.Windows.Forms.MenuItem
    Friend WithEvents mnuExit As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearInk1 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearIcons1 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearIcons2 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuClearInk2 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuAbout As System.Windows.Forms.MenuItem
    Friend WithEvents mnuCustomIcon As System.Windows.Forms.MenuItem
    Friend WithEvents mnuTextLabel As System.Windows.Forms.MenuItem
    Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
    Friend WithEvents mnuInk As System.Windows.Forms.MenuItem
    Friend WithEvents mnuIcons As System.Windows.Forms.MenuItem
    Friend WithEvents mnuPaper As System.Windows.Forms.MenuItem
    Friend WithEvents mnuNetwork As System.Windows.Forms.MenuItem
    Friend WithEvents mnuComputers As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc1 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc2 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc3 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc4 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc5 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc6 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc7 As System.Windows.Forms.MenuItem
    Friend WithEvents mnuspc8 As System.Windows.Forms.MenuItem
    Friend WithEvents IconTabBar As System.Windows.Forms.TabControl
    Friend WithEvents NetworkTab As System.Windows.Forms.TabPage
    Friend WithEvents ComputersTab As System.Windows.Forms.TabPage
    Friend WithEvents mnuWindow As System.Windows.Forms.MenuItem
    Friend WithEvents mnuCascade As System.Windows.Forms.MenuItem
    Friend WithEvents mnuHorizontal As System.Windows.Forms.MenuItem
    Friend WithEvents mnuVertical As System.Windows.Forms.MenuItem
    Friend WithEvents InkToolBar1 As UTE.InkBar.InkToolBar
    Friend WithEvents IconMenu As System.Windows.Forms.ContextMenu
    Friend WithEvents mnuDeleteIcon As System.Windows.Forms.MenuItem
    Friend WithEvents NetworkPanel As System.Windows.Forms.Panel
    Friend WithEvents ComputerPanel As System.Windows.Forms.Panel
    Friend WithEvents Status As System.Windows.Forms.StatusBar
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container
        Dim DrawingAttributes1 As Microsoft.Ink.DrawingAttributes = New Microsoft.Ink.DrawingAttributes
        Dim DrawingAttributes2 As Microsoft.Ink.DrawingAttributes = New Microsoft.Ink.DrawingAttributes
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain))
        Me.MainMenu1 = New System.Windows.Forms.MainMenu(Me.components)
        Me.mnuFile = New System.Windows.Forms.MenuItem
        Me.mnuNew = New System.Windows.Forms.MenuItem
        Me.mnuOpen = New System.Windows.Forms.MenuItem
        Me.mnuspc1 = New System.Windows.Forms.MenuItem
        Me.mnuSave = New System.Windows.Forms.MenuItem
        Me.mnuSaveImage = New System.Windows.Forms.MenuItem
        Me.mnuspc2 = New System.Windows.Forms.MenuItem
        Me.mnuPrintPreview = New System.Windows.Forms.MenuItem
        Me.mnuPrint = New System.Windows.Forms.MenuItem
        Me.mnuspc3 = New System.Windows.Forms.MenuItem
        Me.mnuExit = New System.Windows.Forms.MenuItem
        Me.mnuInk = New System.Windows.Forms.MenuItem
        Me.mnuClearInk1 = New System.Windows.Forms.MenuItem
        Me.mnuspc4 = New System.Windows.Forms.MenuItem
        Me.LN = New System.Windows.Forms.MenuItem
        Me.FF = New System.Windows.Forms.MenuItem
        Me.mnuIcons = New System.Windows.Forms.MenuItem
        Me.mnuClearIcons1 = New System.Windows.Forms.MenuItem
        Me.mnuspc5 = New System.Windows.Forms.MenuItem
        Me.mnuTextLabel = New System.Windows.Forms.MenuItem
        Me.mnuspc6 = New System.Windows.Forms.MenuItem
        Me.mnuNetwork = New System.Windows.Forms.MenuItem
        Me.RTR2 = New System.Windows.Forms.MenuItem
        Me.L32 = New System.Windows.Forms.MenuItem
        Me.MenuItem24 = New System.Windows.Forms.MenuItem
        Me.FW2 = New System.Windows.Forms.MenuItem
        Me.IDS2 = New System.Windows.Forms.MenuItem
        Me.VPN2 = New System.Windows.Forms.MenuItem
        Me.MenuItem25 = New System.Windows.Forms.MenuItem
        Me.SW2 = New System.Windows.Forms.MenuItem
        Me.HB2 = New System.Windows.Forms.MenuItem
        Me.MAU2 = New System.Windows.Forms.MenuItem
        Me.MenuItem26 = New System.Windows.Forms.MenuItem
        Me.WAP2 = New System.Windows.Forms.MenuItem
        Me.mnuComputers = New System.Windows.Forms.MenuItem
        Me.SV2 = New System.Windows.Forms.MenuItem
        Me.MSRV2 = New System.Windows.Forms.MenuItem
        Me.DSRV2 = New System.Windows.Forms.MenuItem
        Me.BSRV2 = New System.Windows.Forms.MenuItem
        Me.WSRV2 = New System.Windows.Forms.MenuItem
        Me.MenuItem23 = New System.Windows.Forms.MenuItem
        Me.LP2 = New System.Windows.Forms.MenuItem
        Me.TB2 = New System.Windows.Forms.MenuItem
        Me.PC2 = New System.Windows.Forms.MenuItem
        Me.mnuspc7 = New System.Windows.Forms.MenuItem
        Me.USR2 = New System.Windows.Forms.MenuItem
        Me.mnuspc8 = New System.Windows.Forms.MenuItem
        Me.mnuCustomIcon = New System.Windows.Forms.MenuItem
        Me.mnuPaper = New System.Windows.Forms.MenuItem
        Me.PlainPaper = New System.Windows.Forms.MenuItem
        Me.MenuItem17 = New System.Windows.Forms.MenuItem
        Me.LoadPaper = New System.Windows.Forms.MenuItem
        Me.MenuItem61 = New System.Windows.Forms.MenuItem
        Me.SGraphPaper = New System.Windows.Forms.MenuItem
        Me.MGraphPaper = New System.Windows.Forms.MenuItem
        Me.LGraphPaper = New System.Windows.Forms.MenuItem
        Me.MenuItem48 = New System.Windows.Forms.MenuItem
        Me.Z2VPaper = New System.Windows.Forms.MenuItem
        Me.Z2HPaper = New System.Windows.Forms.MenuItem
        Me.MenuItem51 = New System.Windows.Forms.MenuItem
        Me.Z3Paper = New System.Windows.Forms.MenuItem
        Me.MenuItem58 = New System.Windows.Forms.MenuItem
        Me.Z4Paper = New System.Windows.Forms.MenuItem
        Me.Z4PPaper = New System.Windows.Forms.MenuItem
        Me.mnuWindow = New System.Windows.Forms.MenuItem
        Me.mnuCascade = New System.Windows.Forms.MenuItem
        Me.mnuHorizontal = New System.Windows.Forms.MenuItem
        Me.mnuVertical = New System.Windows.Forms.MenuItem
        Me.mnuAbout = New System.Windows.Forms.MenuItem
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        Me.InkMenu = New System.Windows.Forms.ContextMenu
        Me.mnuClearInk2 = New System.Windows.Forms.MenuItem
        Me.mnuClearIcons2 = New System.Windows.Forms.MenuItem
        Me.MenuItem19 = New System.Windows.Forms.MenuItem
        Me.MenuItem36 = New System.Windows.Forms.MenuItem
        Me.RTR1 = New System.Windows.Forms.MenuItem
        Me.L31 = New System.Windows.Forms.MenuItem
        Me.MenuItem42 = New System.Windows.Forms.MenuItem
        Me.FW1 = New System.Windows.Forms.MenuItem
        Me.IDS1 = New System.Windows.Forms.MenuItem
        Me.VPN1 = New System.Windows.Forms.MenuItem
        Me.MenuItem9 = New System.Windows.Forms.MenuItem
        Me.SW1 = New System.Windows.Forms.MenuItem
        Me.HB1 = New System.Windows.Forms.MenuItem
        Me.MAU1 = New System.Windows.Forms.MenuItem
        Me.MenuItem52 = New System.Windows.Forms.MenuItem
        Me.WAP1 = New System.Windows.Forms.MenuItem
        Me.MenuItem54 = New System.Windows.Forms.MenuItem
        Me.MenuItem15 = New System.Windows.Forms.MenuItem
        Me.SV1 = New System.Windows.Forms.MenuItem
        Me.MSRV1 = New System.Windows.Forms.MenuItem
        Me.DSRV1 = New System.Windows.Forms.MenuItem
        Me.BSRV1 = New System.Windows.Forms.MenuItem
        Me.WSRV1 = New System.Windows.Forms.MenuItem
        Me.MenuItem56 = New System.Windows.Forms.MenuItem
        Me.LP1 = New System.Windows.Forms.MenuItem
        Me.TB1 = New System.Windows.Forms.MenuItem
        Me.PC1 = New System.Windows.Forms.MenuItem
        Me.USR1 = New System.Windows.Forms.MenuItem
        Me.MenuItem70 = New System.Windows.Forms.MenuItem
        Me.MenuItem37 = New System.Windows.Forms.MenuItem
        Me.MenuItem69 = New System.Windows.Forms.MenuItem
        Me.MenuItem62 = New System.Windows.Forms.MenuItem
        Me.LN1 = New System.Windows.Forms.MenuItem
        Me.FF1 = New System.Windows.Forms.MenuItem
        Me.SaveFileDialog1 = New System.Windows.Forms.SaveFileDialog
        Me.OpenFileDialog1 = New System.Windows.Forms.OpenFileDialog
        Me.OSD = New System.Windows.Forms.OpenFileDialog
        Me.SSD = New System.Windows.Forms.SaveFileDialog
        Me.PrintDocument1 = New System.Drawing.Printing.PrintDocument
        Me.IconTabBar = New System.Windows.Forms.TabControl
        Me.NetworkTab = New System.Windows.Forms.TabPage
        Me.NetworkPanel = New System.Windows.Forms.Panel
        Me.ComputersTab = New System.Windows.Forms.TabPage
        Me.ComputerPanel = New System.Windows.Forms.Panel
        Me.IconMenu = New System.Windows.Forms.ContextMenu
        Me.mnuDeleteIcon = New System.Windows.Forms.MenuItem
        Me.Status = New System.Windows.Forms.StatusBar
        Me.InkToolBar1 = New UTE.InkBar.InkToolBar
        Me.IconTabBar.SuspendLayout()
        Me.NetworkTab.SuspendLayout()
        Me.ComputersTab.SuspendLayout()
        Me.SuspendLayout()
        '
        'MainMenu1
        '
        Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuInk, Me.mnuIcons, Me.mnuPaper, Me.mnuWindow, Me.mnuAbout})
        '
        'mnuFile
        '
        Me.mnuFile.Index = 0
        Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuNew, Me.mnuOpen, Me.mnuspc1, Me.mnuSave, Me.mnuSaveImage, Me.mnuspc2, Me.mnuPrintPreview, Me.mnuPrint, Me.mnuspc3, Me.mnuExit})
        Me.mnuFile.Text = "&File"
        '
        'mnuNew
        '
        Me.mnuNew.Index = 0
        Me.mnuNew.Text = "&New"
        '
        'mnuOpen
        '
        Me.mnuOpen.Index = 1
        Me.mnuOpen.Text = "Open"
        '
        'mnuspc1
        '
        Me.mnuspc1.Index = 2
        Me.mnuspc1.Text = "-"
        '
        'mnuSave
        '
        Me.mnuSave.Index = 3
        Me.mnuSave.Text = "Save"
        '
        'mnuSaveImage
        '
        Me.mnuSaveImage.Index = 4
        Me.mnuSaveImage.Text = "Save as Image"
        '
        'mnuspc2
        '
        Me.mnuspc2.Index = 5
        Me.mnuspc2.Text = "-"
        '
        'mnuPrintPreview
        '
        Me.mnuPrintPreview.Index = 6
        Me.mnuPrintPreview.Text = "Print Preview"
        '
        'mnuPrint
        '
        Me.mnuPrint.Index = 7
        Me.mnuPrint.Text = "Print"
        '
        'mnuspc3
        '
        Me.mnuspc3.Index = 8
        Me.mnuspc3.Text = "-"
        '
        'mnuExit
        '
        Me.mnuExit.Index = 9
        Me.mnuExit.Text = "E&xit"
        '
        'mnuInk
        '
        Me.mnuInk.Index = 1
        Me.mnuInk.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuClearInk1, Me.mnuspc4, Me.LN, Me.FF})
        Me.mnuInk.Text = "&Ink"
        Me.mnuInk.Visible = False
        '
        'mnuClearInk1
        '
        Me.mnuClearInk1.Index = 0
        Me.mnuClearInk1.Text = "Clear Ink"
        '
        'mnuspc4
        '
        Me.mnuspc4.Index = 1
        Me.mnuspc4.Text = "-"
        '
        'LN
        '
        Me.LN.Index = 2
        Me.LN.RadioCheck = True
        Me.LN.Text = "Draw Lines"
        '
        'FF
        '
        Me.FF.Checked = True
        Me.FF.Index = 3
        Me.FF.RadioCheck = True
        Me.FF.Text = "Draw Freeform"
        '
        'mnuIcons
        '
        Me.mnuIcons.Index = 2
        Me.mnuIcons.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuClearIcons1, Me.mnuspc5, Me.mnuTextLabel, Me.mnuspc6, Me.mnuNetwork, Me.mnuComputers, Me.mnuspc7, Me.USR2, Me.mnuspc8, Me.mnuCustomIcon})
        Me.mnuIcons.Text = "Icons"
        Me.mnuIcons.Visible = False
        '
        'mnuClearIcons1
        '
        Me.mnuClearIcons1.Index = 0
        Me.mnuClearIcons1.Text = "Clear Icons"
        '
        'mnuspc5
        '
        Me.mnuspc5.Index = 1
        Me.mnuspc5.Text = "-"
        '
        'mnuTextLabel
        '
        Me.mnuTextLabel.Index = 2
        Me.mnuTextLabel.Text = "Text Label"
        '
        'mnuspc6
        '
        Me.mnuspc6.Index = 3
        Me.mnuspc6.Text = "-"
        '
        'mnuNetwork
        '
        Me.mnuNetwork.Index = 4
        Me.mnuNetwork.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.RTR2, Me.L32, Me.MenuItem24, Me.FW2, Me.IDS2, Me.VPN2, Me.MenuItem25, Me.SW2, Me.HB2, Me.MAU2, Me.MenuItem26, Me.WAP2})
        Me.mnuNetwork.Text = "Network"
        '
        'RTR2
        '
        Me.RTR2.Index = 0
        Me.RTR2.Text = "Router"
        '
        'L32
        '
        Me.L32.Index = 1
        Me.L32.Text = "Layer3 Switch"
        '
        'MenuItem24
        '
        Me.MenuItem24.Index = 2
        Me.MenuItem24.Text = "-"
        '
        'FW2
        '
        Me.FW2.Index = 3
        Me.FW2.Text = "Firewall"
        '
        'IDS2
        '
        Me.IDS2.Index = 4
        Me.IDS2.Text = "IDS"
        '
        'VPN2
        '
        Me.VPN2.Index = 5
        Me.VPN2.Text = "VPN"
        '
        'MenuItem25
        '
        Me.MenuItem25.Index = 6
        Me.MenuItem25.Text = "-"
        '
        'SW2
        '
        Me.SW2.Index = 7
        Me.SW2.Text = "Switch"
        '
        'HB2
        '
        Me.HB2.Index = 8
        Me.HB2.Text = "Hub"
        '
        'MAU2
        '
        Me.MAU2.Index = 9
        Me.MAU2.Text = "MAU"
        '
        'MenuItem26
        '
        Me.MenuItem26.Index = 10
        Me.MenuItem26.Text = "-"
        '
        'WAP2
        '
        Me.WAP2.Index = 11
        Me.WAP2.Text = "WAP"
        '
        'mnuComputers
        '
        Me.mnuComputers.Index = 5
        Me.mnuComputers.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.SV2, Me.MSRV2, Me.DSRV2, Me.BSRV2, Me.WSRV2, Me.MenuItem23, Me.LP2, Me.TB2, Me.PC2})
        Me.mnuComputers.Text = "Computer(s)"
        '
        'SV2
        '
        Me.SV2.Index = 0
        Me.SV2.Text = "Server"
        '
        'MSRV2
        '
        Me.MSRV2.Index = 1
        Me.MSRV2.Text = "Mail Server"
        '
        'DSRV2
        '
        Me.DSRV2.Index = 2
        Me.DSRV2.Text = "Directory Server"
        '
        'BSRV2
        '
        Me.BSRV2.Index = 3
        Me.BSRV2.Text = "DB Server"
        '
        'WSRV2
        '
        Me.WSRV2.Index = 4
        Me.WSRV2.Text = "Web Server"
        '
        'MenuItem23
        '
        Me.MenuItem23.Index = 5
        Me.MenuItem23.Text = "-"
        '
        'LP2
        '
        Me.LP2.Index = 6
        Me.LP2.Text = "Laptop"
        '
        'TB2
        '
        Me.TB2.Index = 7
        Me.TB2.Text = "Tablet"
        '
        'PC2
        '
        Me.PC2.Index = 8
        Me.PC2.Text = "PC"
        '
        'mnuspc7
        '
        Me.mnuspc7.Index = 6
        Me.mnuspc7.Text = "-"
        '
        'USR2
        '
        Me.USR2.Index = 7
        Me.USR2.Text = "User"
        '
        'mnuspc8
        '
        Me.mnuspc8.Index = 8
        Me.mnuspc8.Text = "-"
        '
        'mnuCustomIcon
        '
        Me.mnuCustomIcon.Index = 9
        Me.mnuCustomIcon.Text = "Custom"
        '
        'mnuPaper
        '
        Me.mnuPaper.Index = 3
        Me.mnuPaper.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.PlainPaper, Me.MenuItem17, Me.LoadPaper, Me.MenuItem61, Me.SGraphPaper, Me.MGraphPaper, Me.LGraphPaper, Me.MenuItem48, Me.Z2VPaper, Me.Z2HPaper, Me.MenuItem51, Me.Z3Paper, Me.MenuItem58, Me.Z4Paper, Me.Z4PPaper})
        Me.mnuPaper.Text = "Paper"
        '
        'PlainPaper
        '
        Me.PlainPaper.Checked = True
        Me.PlainPaper.Index = 0
        Me.PlainPaper.RadioCheck = True
        Me.PlainPaper.Text = "Plain White"
        '
        'MenuItem17
        '
        Me.MenuItem17.Index = 1
        Me.MenuItem17.Text = "-"
        '
        'LoadPaper
        '
        Me.LoadPaper.Index = 2
        Me.LoadPaper.RadioCheck = True
        Me.LoadPaper.Text = "Load Image"
        '
        'MenuItem61
        '
        Me.MenuItem61.Index = 3
        Me.MenuItem61.Text = "-"
        '
        'SGraphPaper
        '
        Me.SGraphPaper.Index = 4
        Me.SGraphPaper.RadioCheck = True
        Me.SGraphPaper.Text = "Small Graph"
        '
        'MGraphPaper
        '
        Me.MGraphPaper.Index = 5
        Me.MGraphPaper.RadioCheck = True
        Me.MGraphPaper.Text = "Medium Graph"
        '
        'LGraphPaper
        '
        Me.LGraphPaper.Index = 6
        Me.LGraphPaper.RadioCheck = True
        Me.LGraphPaper.Text = "Large Graph"
        '
        'MenuItem48
        '
        Me.MenuItem48.Index = 7
        Me.MenuItem48.RadioCheck = True
        Me.MenuItem48.Text = "-"
        '
        'Z2VPaper
        '
        Me.Z2VPaper.Index = 8
        Me.Z2VPaper.RadioCheck = True
        Me.Z2VPaper.Text = "2 Zones (Vertical)"
        '
        'Z2HPaper
        '
        Me.Z2HPaper.Index = 9
        Me.Z2HPaper.RadioCheck = True
        Me.Z2HPaper.Text = "2 Zones (Horizontal)"
        '
        'MenuItem51
        '
        Me.MenuItem51.Index = 10
        Me.MenuItem51.RadioCheck = True
        Me.MenuItem51.Text = "-"
        '
        'Z3Paper
        '
        Me.Z3Paper.Index = 11
        Me.Z3Paper.RadioCheck = True
        Me.Z3Paper.Text = "3 Zones"
        '
        'MenuItem58
        '
        Me.MenuItem58.Index = 12
        Me.MenuItem58.RadioCheck = True
        Me.MenuItem58.Text = "-"
        '
        'Z4Paper
        '
        Me.Z4Paper.Index = 13
        Me.Z4Paper.RadioCheck = True
        Me.Z4Paper.Text = "4 Zones"
        '
        'Z4PPaper
        '
        Me.Z4PPaper.Index = 14
        Me.Z4PPaper.RadioCheck = True
        Me.Z4PPaper.Text = "4 Zones (Pyramid)"
        '
        'mnuWindow
        '
        Me.mnuWindow.Index = 4
        Me.mnuWindow.MdiList = True
        Me.mnuWindow.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuCascade, Me.mnuHorizontal, Me.mnuVertical})
        Me.mnuWindow.Text = "Window"
        '
        'mnuCascade
        '
        Me.mnuCascade.Index = 0
        Me.mnuCascade.Text = "Cascade"
        '
        'mnuHorizontal
        '
        Me.mnuHorizontal.Index = 1
        Me.mnuHorizontal.Text = "Tile Horizontal"
        '
        'mnuVertical
        '
        Me.mnuVertical.Index = 2
        Me.mnuVertical.Text = "Tile Vertical"
        '
        'mnuAbout
        '
        Me.mnuAbout.Index = 5
        Me.mnuAbout.Text = "About"
        '
        'Timer1
        '
        '
        'InkMenu
        '
        Me.InkMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuClearInk2, Me.mnuClearIcons2, Me.MenuItem19, Me.MenuItem36, Me.MenuItem15, Me.USR1, Me.MenuItem70, Me.MenuItem37, Me.MenuItem69, Me.MenuItem62, Me.LN1, Me.FF1})
        '
        'mnuClearInk2
        '
        Me.mnuClearInk2.Index = 0
        Me.mnuClearInk2.Text = "Clear Ink"
        '
        'mnuClearIcons2
        '
        Me.mnuClearIcons2.Index = 1
        Me.mnuClearIcons2.Text = "Clear Icons"
        '
        'MenuItem19
        '
        Me.MenuItem19.Index = 2
        Me.MenuItem19.Text = "-"
        '
        'MenuItem36
        '
        Me.MenuItem36.Index = 3
        Me.MenuItem36.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.RTR1, Me.L31, Me.MenuItem42, Me.FW1, Me.IDS1, Me.VPN1, Me.MenuItem9, Me.SW1, Me.HB1, Me.MAU1, Me.MenuItem52, Me.WAP1, Me.MenuItem54})
        Me.MenuItem36.Text = "&Network Icons"
        '
        'RTR1
        '
        Me.RTR1.Index = 0
        Me.RTR1.Text = "Router"
        '
        'L31
        '
        Me.L31.Index = 1
        Me.L31.Text = "Layer3 Switch"
        '
        'MenuItem42
        '
        Me.MenuItem42.Index = 2
        Me.MenuItem42.Text = "-"
        '
        'FW1
        '
        Me.FW1.Index = 3
        Me.FW1.Text = "Firewall"
        '
        'IDS1
        '
        Me.IDS1.Index = 4
        Me.IDS1.Text = "IDS"
        '
        'VPN1
        '
        Me.VPN1.Index = 5
        Me.VPN1.Text = "VPN"
        '
        'MenuItem9
        '
        Me.MenuItem9.Index = 6
        Me.MenuItem9.Text = "-"
        '
        'SW1
        '
        Me.SW1.Index = 7
        Me.SW1.Text = "Switch"
        '
        'HB1
        '
        Me.HB1.Index = 8
        Me.HB1.Text = "Hub"
        '
        'MAU1
        '
        Me.MAU1.Index = 9
        Me.MAU1.Text = "MAU"
        '
        'MenuItem52
        '
        Me.MenuItem52.Index = 10
        Me.MenuItem52.Text = "-"
        '
        'WAP1
        '
        Me.WAP1.Index = 11
        Me.WAP1.Text = "WAP"
        '
        'MenuItem54
        '
        Me.MenuItem54.Index = 12
        Me.MenuItem54.Text = "-"
        '
        'MenuItem15
        '
        Me.MenuItem15.Index = 4
        Me.MenuItem15.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.SV1, Me.MSRV1, Me.DSRV1, Me.BSRV1, Me.WSRV1, Me.MenuItem56, Me.LP1, Me.TB1, Me.PC1})
        Me.MenuItem15.Text = "Computer Icons"
        '
        'SV1
        '
        Me.SV1.Index = 0
        Me.SV1.Text = "Server"
        '
        'MSRV1
        '
        Me.MSRV1.Index = 1
        Me.MSRV1.Text = "Mail Server"
        '
        'DSRV1
        '
        Me.DSRV1.Index = 2
        Me.DSRV1.Text = "Directory Server"
        '
        'BSRV1
        '
        Me.BSRV1.Index = 3
        Me.BSRV1.Text = "DB Server"
        '
        'WSRV1
        '
        Me.WSRV1.Index = 4
        Me.WSRV1.Text = "Web Server"
        '
        'MenuItem56
        '
        Me.MenuItem56.Index = 5
        Me.MenuItem56.Text = "-"
        '
        'LP1
        '
        Me.LP1.Index = 6
        Me.LP1.Text = "Laptop"
        '
        'TB1
        '
        Me.TB1.Index = 7
        Me.TB1.Text = "Tablet"
        '
        'PC1
        '
        Me.PC1.Index = 8
        Me.PC1.Text = "PC"
        '
        'USR1
        '
        Me.USR1.Index = 5
        Me.USR1.Text = "User"
        '
        'MenuItem70
        '
        Me.MenuItem70.Index = 6
        Me.MenuItem70.Text = "-"
        '
        'MenuItem37
        '
        Me.MenuItem37.Index = 7
        Me.MenuItem37.Text = "Text Label"
        '
        'MenuItem69
        '
        Me.MenuItem69.Index = 8
        Me.MenuItem69.Text = "Custom Icon"
        '
        'MenuItem62
        '
        Me.MenuItem62.Index = 9
        Me.MenuItem62.Text = "-"
        '
        'LN1
        '
        Me.LN1.Index = 10
        Me.LN1.RadioCheck = True
        Me.LN1.Text = "Draw Lines"
        '
        'FF1
        '
        Me.FF1.Checked = True
        Me.FF1.Index = 11
        Me.FF1.RadioCheck = True
        Me.FF1.Text = "Draw Freeform"
        '
        'SaveFileDialog1
        '
        Me.SaveFileDialog1.DefaultExt = "JPG"
        Me.SaveFileDialog1.Filter = ".JPG|*.jpg"
        Me.SaveFileDialog1.Title = "Save Picture"
        '
        'OpenFileDialog1
        '
        Me.OpenFileDialog1.Filter = "Image Files (JPG/BMP/GIF)| *.jpg;*.bmp;*.gif"
        Me.OpenFileDialog1.Title = "Select Background Image"
        '
        'OSD
        '
        Me.OSD.DefaultExt = "wbd"
        Me.OSD.Filter = "WhiteBoard .wbd|*.wbd"
        Me.OSD.Title = "Open Whiteboard File"
        '
        'SSD
        '
        Me.SSD.DefaultExt = "wbd"
        Me.SSD.Filter = "WhiteBoard .wbd|*.wbd"
        '
        'PrintDocument1
        '
        '
        'IconTabBar
        '
        Me.IconTabBar.Alignment = System.Windows.Forms.TabAlignment.Left
        Me.IconTabBar.Controls.Add(Me.NetworkTab)
        Me.IconTabBar.Controls.Add(Me.ComputersTab)
        Me.IconTabBar.Dock = System.Windows.Forms.DockStyle.Left
        Me.IconTabBar.Location = New System.Drawing.Point(0, 0)
        Me.IconTabBar.Multiline = True
        Me.IconTabBar.Name = "IconTabBar"
        Me.IconTabBar.SelectedIndex = 0
        Me.IconTabBar.Size = New System.Drawing.Size(56, 317)
        Me.IconTabBar.TabIndex = 9
        '
        'NetworkTab
        '
        Me.NetworkTab.BackColor = System.Drawing.Color.White
        Me.NetworkTab.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.NetworkTab.Controls.Add(Me.NetworkPanel)
        Me.NetworkTab.Location = New System.Drawing.Point(23, 4)
        Me.NetworkTab.Name = "NetworkTab"
        Me.NetworkTab.Size = New System.Drawing.Size(29, 309)
        Me.NetworkTab.TabIndex = 0
        Me.NetworkTab.Text = "Networking"
        '
        'NetworkPanel
        '
        Me.NetworkPanel.BackColor = System.Drawing.Color.White
        Me.NetworkPanel.Location = New System.Drawing.Point(0, 0)
        Me.NetworkPanel.Name = "NetworkPanel"
        Me.NetworkPanel.Size = New System.Drawing.Size(25, 272)
        Me.NetworkPanel.TabIndex = 11
        '
        'ComputersTab
        '
        Me.ComputersTab.BackColor = System.Drawing.Color.White
        Me.ComputersTab.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
        Me.ComputersTab.Controls.Add(Me.ComputerPanel)
        Me.ComputersTab.Location = New System.Drawing.Point(23, 4)
        Me.ComputersTab.Name = "ComputersTab"
        Me.ComputersTab.Size = New System.Drawing.Size(29, 329)
        Me.ComputersTab.TabIndex = 1
        Me.ComputersTab.Text = "Computers"
        '
        'ComputerPanel
        '
        Me.ComputerPanel.BackColor = System.Drawing.Color.White
        Me.ComputerPanel.Location = New System.Drawing.Point(0, 0)
        Me.ComputerPanel.Name = "ComputerPanel"
        Me.ComputerPanel.Size = New System.Drawing.Size(25, 272)
        Me.ComputerPanel.TabIndex = 13
        '
        'IconMenu
        '
        Me.IconMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuDeleteIcon})
        '
        'mnuDeleteIcon
        '
        Me.mnuDeleteIcon.Index = 0
        Me.mnuDeleteIcon.Text = "Delete"
        '
        'Status
        '
        Me.Status.Location = New System.Drawing.Point(56, 295)
        Me.Status.Name = "Status"
        Me.Status.Size = New System.Drawing.Size(672, 22)
        Me.Status.SizingGrip = False
        Me.Status.TabIndex = 11
        '
        'InkToolBar1
        '
        Me.InkToolBar1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
        Me.InkToolBar1.ButtonSize = New System.Drawing.Size(31, 30)
        DrawingAttributes1.AntiAliased = True
        DrawingAttributes1.Color = System.Drawing.Color.Yellow
        DrawingAttributes1.FitToCurve = False
        DrawingAttributes1.Height = 600.0!
        DrawingAttributes1.IgnorePressure = False
        DrawingAttributes1.PenTip = Microsoft.Ink.PenTip.Rectangle
        DrawingAttributes1.RasterOperation = Microsoft.Ink.RasterOperation.CopyPen
        DrawingAttributes1.Transparency = CType(178, Byte)
        DrawingAttributes1.Width = 100.0!
        Me.InkToolBar1.DefaultHighlighterSettings = DrawingAttributes1
        DrawingAttributes2.AntiAliased = True
        DrawingAttributes2.Color = System.Drawing.Color.Black
        DrawingAttributes2.FitToCurve = True
        DrawingAttributes2.Height = 60.0!
        DrawingAttributes2.IgnorePressure = False
        DrawingAttributes2.PenTip = Microsoft.Ink.PenTip.Ball
        DrawingAttributes2.RasterOperation = Microsoft.Ink.RasterOperation.CopyPen
        DrawingAttributes2.Transparency = CType(0, Byte)
        DrawingAttributes2.Width = 60.0!
        Me.InkToolBar1.DefaultPenSettings = DrawingAttributes2
        Me.InkToolBar1.Divider = False
        Me.InkToolBar1.Location = New System.Drawing.Point(56, 0)
        Me.InkToolBar1.Name = "InkToolBar1"
        Me.InkToolBar1.Size = New System.Drawing.Size(672, 35)
        Me.InkToolBar1.TabIndex = 0
        '
        'frmMain
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.BackColor = System.Drawing.SystemColors.Control
        Me.ClientSize = New System.Drawing.Size(728, 317)
        Me.Controls.Add(Me.Status)
        Me.Controls.Add(Me.InkToolBar1)
        Me.Controls.Add(Me.IconTabBar)
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.IsMdiContainer = True
        Me.Menu = Me.MainMenu1
        Me.Name = "frmMain"
        Me.Text = "Network Whiteboard"
        Me.IconTabBar.ResumeLayout(False)
        Me.NetworkTab.ResumeLayout(False)
        Me.ComputersTab.ResumeLayout(False)
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub

#End Region






    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load



        Me.Text = "Network Whiteboard - " & Version
        SetupNetworkToolbar()
        SetupComputerToolbar()
        'Setup the timer that allows for repositioning icons
        mMove.Initialize(Timer1)

        'Check to see if it is trying to open an existing drawing
        If CheckArg() Then
            OpenArgFile()
        Else
            CreateNewDrawing()
        End If

        SetInkAttribs()


    End Sub

    Private Sub SetInkAttribs()
        If Not c Is Nothing Then
            c.InkBox.InkBox.DefaultDrawingAttributes = InkToolBar1.InkDrawingAttributes
        End If
    End Sub

    Private Sub CreateNewDrawing()
        Dim t As New frmDrawing
        t.MdiParent = Me
        c = t
        t.Show()
    End Sub

    Private Sub OpenArgFile()
        Dim F As String = Microsoft.VisualBasic.Command.Replace("""", "")
        OpenInk(F)
    End Sub
    Private Function CheckArg() As Boolean
        If Microsoft.VisualBasic.Command <> Nothing Then
            Dim F As String = Microsoft.VisualBasic.Command.Replace("""", "")
            If IO.File.Exists(F) Then
                Return True
            Else
                Return False
            End If
        Else
            Return False
        End If
    End Function

#Region "Icon Click and Move Event Handlers"
    Private Sub ImgDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Button = MouseButtons.Left Then mMove.Begin(sender, e.X, e.Y)
    End Sub
    Private Sub ImgUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Button = MouseButtons.Left Then mMove.EndIt()
    End Sub
    Private Sub ImgMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        If e.Button = MouseButtons.Left Then mMove.InProgress(e.X, e.Y)
    End Sub
    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        mMove.ToNewPosition()
    End Sub

#End Region


    Private Function GetImageFromName(ByVal Name As String) As Bitmap
        Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
        Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & Name & ".gif")
        Dim image As New Bitmap(myStream)
        image.MakeTransparent(Color.White)
        Return image
    End Function




    Private Sub AddIcon(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles RTR1.Click, WAP1.Click, HB1.Click, SW1.Click, FW1.Click, PC1.Click, IDS1.Click, LP1.Click, SV1.Click, USR1.Click, TB1.Click, RTR2.Click, IDS2.Click, FW2.Click, HB2.Click, SW2.Click, WAP2.Click, SV2.Click, LP2.Click, TB2.Click, PC2.Click, USR2.Click, BSRV1.Click, BSRV2.Click, DSRV1.Click, DSRV2.Click, L31.Click, L32.Click, VPN1.Click, VPN2.Click, MAU1.Click, MAU2.Click, MSRV1.Click, MSRV2.Click, WSRV1.Click, WSRV2.Click
        AddIcon(sender.text)
    End Sub

    Private Function GetFormImage() As Bitmap
        If Not c Is Nothing Then
            Dim B As Bitmap
            Dim G As Graphics
            If c.InkBox.Image Is Nothing Then
                B = New Bitmap(c.InkBox.MinX, c.InkBox.MinY)
                G = Graphics.FromImage(B)
                G.Clear(Color.White)
            Else
                B = c.InkBox.Image.Clone
                G = Graphics.FromImage(B)
            End If

            G.DrawImage(GetInkImage, 0, 0)

            For I As Integer = c.InkBox.Controls.Count - 1 To 0 Step -1
                Dim P As PictureBox = c.InkBox.Controls(I)
                G.DrawImage(P.Image, P.Location)
            Next

            Return B
        End If
        Return Nothing
    End Function

    Private Function GetInkImage() As Bitmap
        'capture the image of what is in the form and save a bitmap
        If Not c Is Nothing Then
            Try

                Dim im As Image
                Dim g As Graphics
                Dim gImage As Graphics
                Dim gTemp As Graphics
                Dim dib As DibGraphicsBuffer
                im = New Bitmap(c.InkBox.Width, c.InkBox.Height)
                g = c.InkBox.CreateGraphics
                gImage = Graphics.FromImage(im)
                dib = New DibGraphicsBuffer
                gTemp = dib.RequestBuffer(g, c.InkBox.Width, c.InkBox.Height)
                gTemp.Clear(c.InkBox.BackColor)
                If Not c.InkBox.Image Is Nothing Then
                    gTemp.DrawImage(c.InkBox.Image, 0, 0)
                End If

                Dim oRender As New Renderer
                oRender.Draw(gTemp, c.InkBox.InkBox.Ink.Strokes)
                dib.PaintBuffer(gImage, 0, 0)
                g.Dispose()
                gImage.Dispose()
                dib.Dispose()
                gTemp.Dispose()
                Return im
            Catch ex As Exception

            End Try
        End If

        Return Nothing
    End Function



    Private Function CreateTextImage(ByVal sImageText As String) As Bitmap

        sImageText = sImageText.ToUpper
        Dim iFontSize As Integer

        iFontSize = 10


        Dim bmpImage As New Bitmap(1, 1)

        Dim iWidth As Integer = 0
        Dim iHeight As Integer = 0

        '// Create the Font object for the image text drawing.
        Dim MyFont As New Font("Verdana", iFontSize, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point)

        '// Create a graphics object to measure the text's width and height.
        'Graphics(MyGraphics = Graphics.FromImage(bmpImage))
        Dim MyGraphics As Graphics
        MyGraphics = Graphics.FromImage(bmpImage)

        '// This is where the bitmap size is determined.
        iWidth = MyGraphics.MeasureString(sImageText, MyFont).Width
        iHeight = MyGraphics.MeasureString(sImageText, MyFont).Height

        '// Create the bmpImage again with the correct size for the text and font.
        bmpImage = New Bitmap(bmpImage, New Size(iWidth, iHeight))

        '// Add the colors to the new bitmap.
        MyGraphics = Graphics.FromImage(bmpImage)
        MyGraphics.Clear(Color.White)
        'MyGraphics.TextRenderingHint = Text.TextRenderingHint.AntiAlias
        MyGraphics.DrawString(sImageText, MyFont, New SolidBrush(Color.Black), 0, 0)
        MyGraphics.Flush()

        'Return bmpImage
        Return bmpImage
    End Function


    Friend Sub UpdateFF()
        If Not c Is Nothing Then
            FF.Checked = c.Freeform
            FF1.Checked = c.Freeform
            LN.Checked = Not c.Freeform
            LN1.Checked = Not c.Freeform
        End If

    End Sub

    Private Sub SaveInk()
        If Not c Is Nothing Then
            If SSD.ShowDialog = DialogResult.OK Then
                c.Text = SSD.FileName
                c.Name = SSD.FileName
                Dim str As IO.Stream = IO.File.OpenWrite(SSD.FileName)
                Dim Buf() As Byte = c.InkBox.InkBox.Ink.Save(Microsoft.Ink.PersistenceFormat.Base64InkSerializedFormat)

                Dim A As New ArrayList
                For Each I As PictureBox In c.InkBox.Controls
                    Dim P As New Pics
                    P.X = I.Location.X
                    P.Y = I.Location.Y
                    P.Image = I.Tag
                    A.Add(P)
                Next
                Dim Pa As New Pics
                A.Add(Buf)
                Dim T(0) As Type
                T(0) = Pa.GetType
                Dim X As New Xml.Serialization.XmlSerializer(A.GetType, T)
                X.Serialize(str, A)
                str.Close()
                c.Dirty = False
            End If
        End If



    End Sub


    Private Sub OpenInk(ByVal File As String)
        c = New frmDrawing
        c.MdiParent = Me
        c.Text = File
        c.Name = File
        ClearAll()
        Dim str As IO.Stream = IO.File.OpenRead(File)
        Dim Buf() As Byte
        Dim A As New ArrayList
        Dim Pa As New Pics
        Dim T(0) As Type
        T(0) = Pa.GetType
        Dim X As New Xml.Serialization.XmlSerializer(A.GetType, T)
        A = X.Deserialize(str)
        str.Close()

        Buf = A(A.Count - 1)
        c.InkBox.Enabled = False
        c.InkBox.InkEnabled = False
        Dim Nink As New Microsoft.Ink.Ink
        Nink.Load(Buf)
        c.InkBox.InkBox.Ink = Nink


        c.InkBox.Enabled = True
        c.InkBox.InkEnabled = True
        For I As Integer = 0 To A.Count - 2
            Dim P As New Pics
            P = A(I)
            Dim R As New PictureBox
            AddHandler R.MouseDown, AddressOf ImgDown
            AddHandler R.MouseMove, AddressOf ImgMove
            AddHandler R.MouseUp, AddressOf ImgUp
            Dim image As Bitmap
            If InStr(P.Image, "TEXT:") > 0 Then
                image = Me.CreateTextImage(P.Image.Substring(P.Image.IndexOf(":") + 1))
            Else
                Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
                Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & P.Image & ".gif")
                image = New Bitmap(myStream)
            End If

            image.MakeTransparent(Color.White)
            R.BackColor = Color.Transparent
            R.Tag = P.Image
            R.Image = image
            R.ContextMenu = IconMenu
            R.Region = BitmapToRegion(image, image.GetPixel(1, 1))
            R.Cursor = System.Windows.Forms.Cursors.SizeAll()


            R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
            R.Location = New Point(P.X, P.Y)

            c.InkBox.Controls.Add(R)
            R.BringToFront()

        Next
        c.InkBox.Refresh()
        c.Show()
    End Sub

#Region "Menu Event Handlers"

    Private Sub ClearAll()
        If Not c Is Nothing Then
            c.InkBox.Controls.Clear()
            c.InkBox.InkBox.Ink.DeleteStrokes(c.InkBox.InkBox.Ink.Strokes)
            c.InkBox.Refresh()
        End If

    End Sub

    Private Sub mnuNew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuNew.Click
        CreateNewDrawing()
    End Sub

    Private Sub mnuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuExit.Click
        Me.Close()
        Application.Exit()
    End Sub



    Private Sub mnuClearInk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClearInk1.Click, mnuClearInk2.Click
        If Not c Is Nothing Then
            c.InkBox.InkBox.Ink.DeleteStrokes(c.InkBox.InkBox.Ink.Strokes)
            c.InkBox.Refresh()
        End If

    End Sub



    Private Sub mnuDeleteIcon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuDeleteIcon.Click
        If Not c Is Nothing Then
            If Not IconMenuPic Is Nothing Then
                c.InkBox.Controls.Remove(IconMenuPic)
            End If
        End If


    End Sub

    Private Sub IconMenu_Popup(ByVal sender As Object, ByVal e As System.EventArgs) Handles IconMenu.Popup
        IconMenuPic = sender.sourcecontrol
    End Sub


    Private Sub ShowAbout()
        With New AboutBox
            .AppTitle = "Network Whiteboard"
            .AppDescription = "A whiteboard for networking equipment."
            .AppVersion = Version
            .AppCopyright = "Copyright Eric Fetty 1999-" & Now.Year
            .AppMoreInfo = "A whiteboard utility to allow quick and easy diagraming of network equipment. This was developed to help IT admins in quick mockups of networking equipment, etc." & vbCrLf & "http://www.kingfetty.com" & vbCrLf & "eric@kingfetty.com"
            .AppDetailsButton = False
            .ShowDialog(Me)
        End With
    End Sub

    Private Sub mnuAbout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuAbout.Click
        ShowAbout()
    End Sub



    Private Sub mnuSaveImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSaveImage.Click
        If SaveFileDialog1.ShowDialog = DialogResult.OK Then
            GetFormImage.Save(SaveFileDialog1.FileName)
        End If
    End Sub

    Private Sub SetPaperMenu(ByVal Paper As PaperType)
        Select Case Paper
            Case PaperType.Plain
                LoadPaper.Checked = False
                PlainPaper.Checked = True
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
            Case PaperType.SmallGraph
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = True
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
            Case PaperType.MediumGraph
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = True
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
            Case PaperType.LargeGraph
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = True
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
            Case PaperType.Zone2Horz
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = True
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
            Case PaperType.Zone2Vert
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = True
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
            Case PaperType.Zone3
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = True
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
            Case PaperType.Zone4
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = True
                Z4PPaper.Checked = False
            Case PaperType.Zone4Pyr
                LoadPaper.Checked = False
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = True
            Case PaperType.Custom
                LoadPaper.Checked = True
                PlainPaper.Checked = False
                SGraphPaper.Checked = False
                MGraphPaper.Checked = False
                LGraphPaper.Checked = False
                Z2VPaper.Checked = False
                Z2HPaper.Checked = False
                Z3Paper.Checked = False
                Z4Paper.Checked = False
                Z4PPaper.Checked = False
        End Select
    End Sub

    Private Sub mnuLoadPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LoadPaper.Click
        If Not c Is Nothing Then
            If OpenFileDialog1.ShowDialog = DialogResult.OK Then
                c.InkBox.BackgroundImage = Nothing
                c.InkBox.Image(True) = Image.FromFile(OpenFileDialog1.FileName)

                SetPaperMenu(PaperType.Custom)
            End If
        End If

    End Sub




    Private Sub PlainPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlainPaper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.Plain)
            c.InkBox.Image(True) = Nothing
            c.InkBox.BackgroundImage = Nothing
        End If

    End Sub

    Private Sub SGraphPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SGraphPaper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.SmallGraph)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)

            c.InkBox.BackgroundImage = image
            c.InkBox.Image(True) = Nothing
        End If
    End Sub

    Private Sub MGraphPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MGraphPaper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.MediumGraph)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)

            c.InkBox.BackgroundImage = image
            c.InkBox.Image(True) = Nothing
        End If
    End Sub

    Private Sub LGraphPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LGraphPaper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.LargeGraph)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)

            c.InkBox.BackgroundImage = image
            c.InkBox.Image(True) = Nothing
        End If
    End Sub

    Private Sub Z2VPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Z2VPaper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.Zone2Vert)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)

            c.InkBox.BackgroundImage = Nothing
            c.InkBox.Image(True) = image

        End If
    End Sub

    Private Sub Z2HPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Z2HPaper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.Zone2Horz)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)
            c.InkBox.BackgroundImage = Nothing
            c.InkBox.Image(True) = image
            '
        End If

    End Sub


    Private Sub Z3Paper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Z3Paper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.Zone3)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)

            c.InkBox.BackgroundImage = Nothing
            c.InkBox.Image(True) = image

        End If
    End Sub

    Private Sub Z4Paper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Z4Paper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.Zone4)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)
            c.InkBox.BackgroundImage = Nothing
            c.InkBox.Image(True) = image

        End If
    End Sub

    Private Sub Z4PPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Z4PPaper.Click
        If Not c Is Nothing Then
            SetPaperMenu(PaperType.Zone4Pyr)

            Dim myAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
            Dim myStream As System.IO.Stream = myAssembly.GetManifestResourceStream("NetworkWhiteboard." & sender.text & ".gif")
            Dim image As New Bitmap(myStream)
            c.InkBox.BackgroundImage = Nothing
            c.InkBox.Image(True) = image

        End If
    End Sub

    Private Sub mnuClearIcons_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuClearIcons1.Click, mnuClearIcons2.Click
        If Not c Is Nothing Then
            c.InkBox.Controls.Clear()
        End If

    End Sub

    Private Sub mnuTextLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem37.Click, mnuTextLabel.Click
        If Not c Is Nothing Then
            Dim R As New PictureBox
            AddHandler R.MouseDown, AddressOf ImgDown
            AddHandler R.MouseMove, AddressOf ImgMove
            AddHandler R.MouseUp, AddressOf ImgUp


            R.ContextMenu = IconMenu
            R.Cursor = System.Windows.Forms.Cursors.SizeAll()


            Dim T As New TextEntry
            Dim X As DialogResult = T.ShowDialog
            If X = DialogResult.OK Then
                If T.InkText.Text.Trim <> "" Then
                    Dim image As Bitmap
                    image = CreateTextImage(T.InkText.Text)
                    image.MakeTransparent(Color.White)
                    R.Tag = "TEXT:" & T.InkText.Text
                    R.BackColor = Color.Transparent
                    R.Region = BitmapToRegion(image, image.GetPixel(1, 1))
                    R.Image = image
                    R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
                    R.Location = New Point(c.InkBox.Width / 2, c.InkBox.Height / 2)
                    c.InkBox.Controls.Add(R)
                    R.BringToFront()
                End If
            End If
            T = Nothing
        End If

    End Sub

    Private Sub LN1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LN1.Click
        If Not c Is Nothing Then
            c.Freeform = False
            UpdateFF()
        End If

    End Sub

    Private Sub FF1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FF1.Click
        If Not c Is Nothing Then
            c.Freeform = True
            UpdateFF()
        End If

    End Sub

    Private Sub LN_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LN.Click
        If Not c Is Nothing Then
            c.Freeform = False
            UpdateFF()
        End If

    End Sub

    Private Sub FF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FF.Click
        If Not c Is Nothing Then
            c.Freeform = True
            UpdateFF()
        End If

    End Sub
    Private Sub mnuSave_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuSave.Click
        If Not c Is Nothing Then
            SaveInk()
        End If
    End Sub

    Private Sub mnuOpen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuOpen.Click
        If OSD.ShowDialog = DialogResult.OK Then
            OpenInk(OSD.FileName)
        End If
    End Sub

    Private Sub mnuCustomIcon_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem69.Click, mnuCustomIcon.Click
        If Not c Is Nothing Then
            If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then

                Dim R As New PictureBox
                R.Name = GetGuid()
                AddHandler R.MouseDown, AddressOf ImgDown
                AddHandler R.MouseMove, AddressOf ImgMove
                AddHandler R.MouseUp, AddressOf ImgUp

                Dim Image As Bitmap = New Bitmap(Me.OpenFileDialog1.FileName)
                R.BackColor = Color.Transparent
                R.Tag = "Custom"
                R.Image = Image
                R.ContextMenu = IconMenu

                R.Region = BitmapToRegion(Image, Image.GetPixel(0, 0))
                R.Cursor = System.Windows.Forms.Cursors.SizeAll()


                R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
                R.Location = New Point(c.InkBox.Width / 2, c.InkBox.Height / 2)

                c.InkBox.Controls.Add(R)
                R.BringToFront()


            End If
        End If

    End Sub

    Private Sub PrintPreview_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrintPreview.Click
        If Not c Is Nothing Then
            Dim printPreviewDlg As New PrintPreviewDialog
            printPreviewDlg.Document = PrintDocument1
            printPreviewDlg.Height = 800
            printPreviewDlg.Width = 600
            printPreviewDlg.ShowDialog()
        End If

    End Sub

    Private Sub Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuPrint.Click
        If Not c Is Nothing Then
            Dim p As New PrintDialog
            p.AllowSelection = False
            p.AllowSomePages = False
            p.AllowPrintToFile = False
            p.ShowHelp = False
            p.Document = PrintDocument1
            If p.ShowDialog = DialogResult.OK Then
                PrintDocument1.PrinterSettings = p.PrinterSettings

                PrintDocument1.Print()
            End If

        End If

    End Sub

    Private Sub PrintDocument1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim B As Bitmap = Me.GetFormImage
        Dim X As Double = 800 / B.Width

        Dim N As New Bitmap(B, B.Width * X, B.Height * X)

        e.Graphics.DrawImage(N, 0, 0)
    End Sub

#End Region

    Private Function GetPicBox(ByVal P As PictureBox) As PictureBox
        If Not c Is Nothing Then
            Dim R As PictureBox = Nothing

            For I As Integer = 0 To c.InkBox.Controls.Count - 1
                If c.InkBox.Controls(I).Name = P.Name Then
                    R = c.InkBox.Controls(I)
                    '  InkBox.Controls.Remove(R)
                End If
            Next

            If R Is Nothing Then
                R = New PictureBox
                R.Name = P.Name

                AddHandler R.MouseDown, AddressOf ImgDown
                AddHandler R.MouseMove, AddressOf ImgMove
                AddHandler R.MouseUp, AddressOf ImgUp

                Dim Image As Bitmap = P.Image

                R.BackColor = Color.Transparent
                R.Tag = Tag
                R.Image = Image

                R.ContextMenu = IconMenu
                R.Region = BitmapToRegion(Image, Image.GetPixel(1, 1))
                R.Cursor = System.Windows.Forms.Cursors.SizeAll()


                R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
            End If


            Return R
        End If
        Return Nothing
    End Function

    Private Function GetPicBox(ByVal Tag As String, ByVal Name As String) As PictureBox

        If Not c Is Nothing Then
            Dim R As PictureBox = Nothing

            For I As Integer = 0 To c.InkBox.Controls.Count - 1
                If c.InkBox.Controls(I).Name = Name Then
                    R = c.InkBox.Controls(I)
                    '  InkBox.Controls.Remove(R)
                End If
            Next

            If R Is Nothing Then
                R = New PictureBox
                R.Name = Name

                AddHandler R.MouseDown, AddressOf ImgDown
                AddHandler R.MouseMove, AddressOf ImgMove
                AddHandler R.MouseUp, AddressOf ImgUp

                Dim Image As Bitmap
                If InStr(Tag, "TEXT:") > 0 Then
                    Image = Me.CreateTextImage(Tag.Substring(Tag.IndexOf(":") + 1))
                Else
                    Image = GetImageFromName(Tag)
                End If
                'Image = Unmanaged.Image
                R.BackColor = Color.Transparent
                R.Tag = Tag
                R.Image = Image

                R.ContextMenu = IconMenu
                R.Region = BitmapToRegion(Image, Image.GetPixel(1, 1))
                R.Cursor = System.Windows.Forms.Cursors.SizeAll()


                R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
            End If


            Return R
        End If
        Return Nothing
    End Function

    Private Function SeralizeImage(ByVal srcImage As Bitmap) As String
        Dim serializerXML As New Xml.Serialization.XmlSerializer(GetType(BMPXMLSerialization))
        Dim writerSerialized As New IO.StringWriter
        Dim writerXMLText As New Xml.XmlTextWriter(writerSerialized)
        serializerXML.Serialize(writerXMLText, New BMPXMLSerialization(srcImage))
        Return writerSerialized.ToString
    End Function

    Private Function DeSerializeImage(ByVal S As String) As Bitmap
        Dim serializerXML As New Xml.Serialization.XmlSerializer(GetType(BMPXMLSerialization))
        Dim newBitmap As Bitmap = CType(serializerXML.Deserialize(New IO.StringReader(S)), BMPXMLSerialization).Bitmap
        Return newBitmap
    End Function

    Private Sub InkToolBar1_SettingsChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InkToolBar1.SettingsChanged
        If Not c Is Nothing Then
            Select Case Me.InkToolBar1.Mode
                Case UTE.InkBar.InkToolBarMode.Pen
                    c.InkBox.InkBox.DefaultDrawingAttributes = InkToolBar1.InkDrawingAttributes
                Case UTE.InkBar.InkToolBarMode.Highlighter
                    c.InkBox.InkBox.DefaultDrawingAttributes = InkToolBar1.InkDrawingAttributes
                Case UTE.InkBar.InkToolBarMode.Eraser
                    c.InkBox.InkBox.EraserMode = InkToolBar1.EraserAttributes.Mode
                    c.InkBox.InkBox.EraserWidth = InkToolBar1.EraserAttributes.Size
                Case Else

            End Select
        End If

    End Sub

    Private Sub InkToolBar1_ModeChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InkToolBar1.ModeChanged
        If Not c Is Nothing Then
            Select Case InkToolBar1.Mode
                Case UTE.InkBar.InkToolBarMode.Eraser
                    c.InkBox.InkBox.Selection = c.InkBox.InkBox.Ink.CreateStrokes
                    c.InkBox.InkBox.EditingMode = InkOverlayEditingMode.Delete
                Case UTE.InkBar.InkToolBarMode.Lasso
                    c.InkBox.InkBox.EditingMode = InkOverlayEditingMode.Select
                Case Else
                    c.InkBox.InkBox.Selection = c.InkBox.InkBox.Ink.CreateStrokes
                    c.InkBox.InkBox.EditingMode = InkOverlayEditingMode.Ink
            End Select
        End If

    End Sub

    Private Sub ToolBar1_ButtonClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolBarButtonClickEventArgs)
        If Not c Is Nothing Then
            If e.Button.ToolTipText = "Text" Then
                AddTextIcon()
            ElseIf e.Button.ToolTipText = "Custom" Then

            Else
                AddIcon(e.Button.ToolTipText)
            End If
        End If


    End Sub

    Friend Sub AddTextIcon(ByVal Location As Point)
        Dim R As New PictureBox
        AddHandler R.MouseDown, AddressOf ImgDown
        AddHandler R.MouseMove, AddressOf ImgMove
        AddHandler R.MouseUp, AddressOf ImgUp


        R.ContextMenu = IconMenu
        R.Cursor = System.Windows.Forms.Cursors.SizeAll()


        Dim T As New TextEntry
        Dim X As DialogResult = T.ShowDialog
        If X = DialogResult.OK Then
            If T.InkText.Text.Trim <> "" Then
                Dim image As Bitmap
                image = CreateTextImage(T.InkText.Text)
                image.MakeTransparent(Color.White)
                R.Tag = "TEXT:" & T.InkText.Text
                R.BackColor = Color.Transparent
                R.Region = BitmapToRegion(image, image.GetPixel(1, 1))
                R.Image = image
                R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
                Location.X = Location.X - (R.Size.Width / 2)
                Location.Y = Location.Y - (R.Size.Height / 2)
                R.Location = Location
                AddHandler R.MouseMove, AddressOf Icon_MouseMove
                c.InkBox.Controls.Add(R)
                R.BringToFront()
            End If
        End If
        T = Nothing
    End Sub

    Private Sub AddTextIcon()
        Dim R As New PictureBox
        AddHandler R.MouseDown, AddressOf ImgDown
        AddHandler R.MouseMove, AddressOf ImgMove
        AddHandler R.MouseUp, AddressOf ImgUp


        R.ContextMenu = IconMenu
        R.Cursor = System.Windows.Forms.Cursors.SizeAll()


        Dim T As New TextEntry
        Dim X As DialogResult = T.ShowDialog
        If X = DialogResult.OK Then
            If T.InkText.Text.Trim <> "" Then
                Dim image As Bitmap
                image = CreateTextImage(T.InkText.Text)
                image.MakeTransparent(Color.White)
                R.Tag = "TEXT:" & T.InkText.Text
                R.BackColor = Color.Transparent
                R.Region = BitmapToRegion(image, image.GetPixel(1, 1))
                R.Image = image
                R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
                R.Location = New Point(c.InkBox.Width / 2, c.InkBox.Height / 2)
                AddHandler R.MouseMove, AddressOf Icon_MouseMove
                c.InkBox.Controls.Add(R)
                R.BringToFront()
            End If
        End If
        T = Nothing
    End Sub

    Private Sub AddCustomIcon()
        If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then

            Dim R As New PictureBox
            R.Name = GetGuid()
            AddHandler R.MouseDown, AddressOf ImgDown
            AddHandler R.MouseMove, AddressOf ImgMove
            AddHandler R.MouseUp, AddressOf ImgUp

            Dim Image As Bitmap = New Bitmap(Me.OpenFileDialog1.FileName)
            R.BackColor = Color.Transparent
            R.Tag = "Custom"
            R.Image = Image
            R.ContextMenu = IconMenu

            R.Region = BitmapToRegion(Image, Image.GetPixel(0, 0))
            R.Cursor = System.Windows.Forms.Cursors.SizeAll()
            AddHandler R.MouseMove, AddressOf Icon_MouseMove

            R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
            R.Location = New Point(c.InkBox.Width / 2, c.InkBox.Height / 2)

            c.InkBox.Controls.Add(R)
            R.BringToFront()


        End If
    End Sub

    Friend Sub AddCustomIcon(ByVal Location As Point)
        If Me.OpenFileDialog1.ShowDialog = DialogResult.OK Then

            Dim R As New PictureBox
            R.Name = GetGuid()
            AddHandler R.MouseDown, AddressOf ImgDown
            AddHandler R.MouseMove, AddressOf ImgMove
            AddHandler R.MouseUp, AddressOf ImgUp

            Dim Image As Bitmap = New Bitmap(Me.OpenFileDialog1.FileName)
            R.BackColor = Color.Transparent
            R.Tag = "Custom"
            R.Image = Image
            R.ContextMenu = IconMenu

            R.Region = BitmapToRegion(Image, Image.GetPixel(0, 0))
            R.Cursor = System.Windows.Forms.Cursors.SizeAll()
            AddHandler R.MouseMove, AddressOf Icon_MouseMove

            R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
            Location.X = Location.X - (R.Size.Width / 2)
            Location.Y = Location.Y - (R.Size.Height / 2)
            R.Location = Location

            c.InkBox.Controls.Add(R)
            R.BringToFront()


        End If
    End Sub

    Private Sub AddIcon(ByVal Name As String)
        If Not c Is Nothing Then
            Dim R As New PictureBox


            'Add event handlers to allow movement
            AddHandler R.MouseDown, AddressOf ImgDown
            AddHandler R.MouseMove, AddressOf ImgMove
            AddHandler R.MouseUp, AddressOf ImgUp

            'Retrieve image based on the name selected
            Dim Image As Bitmap = GetImageFromName(Name)
            R.BackColor = Color.Transparent
            R.Tag = Name
            R.Image = Image
            R.ContextMenu = IconMenu

            R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
            R.Location = New Point(c.InkBox.Width / 2, c.InkBox.Height / 2)

            'Clip the picbox to the image
            R.Region = BitmapToRegion(Image, Image.GetPixel(1, 1))
            AddHandler R.MouseMove, AddressOf Icon_MouseMove
            R.Cursor = System.Windows.Forms.Cursors.SizeAll()

            'Add the new picbox to the ink control
            c.InkBox.Controls.Add(R)
            R.BringToFront()
        End If


    End Sub

    Friend Sub AddIcon(ByVal Image As Bitmap, ByVal Location As Point)

        Dim R As New PictureBox
        R.Name = GetGuid()
        AddHandler R.MouseDown, AddressOf ImgDown
        AddHandler R.MouseMove, AddressOf ImgMove
        AddHandler R.MouseUp, AddressOf ImgUp


        R.BackColor = Color.Transparent
        R.Tag = "Custom"
        R.Image = Image
        R.ContextMenu = IconMenu

        R.Region = BitmapToRegion(Image, Image.GetPixel(0, 0))
        R.Cursor = System.Windows.Forms.Cursors.SizeAll()
        AddHandler R.MouseMove, AddressOf Icon_MouseMove

        R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
        Location.X = Location.X - (R.Size.Width / 2)
        Location.Y = Location.Y - (R.Size.Height / 2)
        R.Location = Location

        c.InkBox.Controls.Add(R)
        R.BringToFront()

    End Sub
    Friend Sub AddIcon(ByVal Name As String, ByVal Location As Point)
        If Not c Is Nothing Then
            Dim R As New PictureBox


            'Add event handlers to allow movement
            AddHandler R.MouseDown, AddressOf ImgDown
            AddHandler R.MouseMove, AddressOf ImgMove
            AddHandler R.MouseUp, AddressOf ImgUp

            'Retrieve image based on the name selected
            Dim Image As Bitmap = GetImageFromName(Name)
            R.BackColor = Color.Transparent
            R.Tag = Name
            R.Image = Image
            R.ContextMenu = IconMenu

            R.Size = New Drawing.Size(R.Image.Width, R.Image.Height)
            Location.X = Location.X - (R.Size.Width / 2)
            Location.Y = Location.Y - (R.Size.Height / 2)
            R.Location = Location

            'Clip the picbox to the image
            R.Region = BitmapToRegion(Image, Image.GetPixel(1, 1))
            AddHandler R.MouseMove, AddressOf Icon_MouseMove


            R.Cursor = System.Windows.Forms.Cursors.SizeAll()

            'Add the new picbox to the ink control
            c.InkBox.Controls.Add(R)
            R.BringToFront()
        End If


    End Sub

    Private Sub mnuCascade_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuCascade.Click
        Me.LayoutMdi(MdiLayout.Cascade)
    End Sub

    Private Sub mnuHorizontal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuHorizontal.Click
        Me.LayoutMdi(MdiLayout.TileHorizontal)
    End Sub

    Private Sub mnuVertical_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mnuVertical.Click
        Me.LayoutMdi(MdiLayout.TileVertical)
    End Sub

    Private Sub frmMain_MdiChildActivate(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.MdiChildActivate
        c = Me.ActiveMdiChild
        If Not c Is Nothing Then
            c.Freeform = FF.Checked
            EnableMenus()
            Select Case Me.InkToolBar1.Mode
                Case UTE.InkBar.InkToolBarMode.Pen
                    c.InkBox.InkBox.DefaultDrawingAttributes = InkToolBar1.InkDrawingAttributes
                Case UTE.InkBar.InkToolBarMode.Highlighter
                    c.InkBox.InkBox.DefaultDrawingAttributes = InkToolBar1.InkDrawingAttributes
                Case UTE.InkBar.InkToolBarMode.Eraser
                    c.InkBox.InkBox.EraserMode = InkToolBar1.EraserAttributes.Mode
                    c.InkBox.InkBox.EraserWidth = InkToolBar1.EraserAttributes.Size
                Case Else
            End Select
        Else
            DisableMenus()
        End If

    End Sub

    Private Sub DisableMenus()
        Me.mnuSave.Enabled = False
        Me.mnuPrint.Enabled = False
        Me.mnuPrintPreview.Enabled = False
        Me.mnuPaper.Enabled = False
        Me.mnuWindow.Enabled = False
        Me.mnuSaveImage.Enabled = False
    End Sub

    Private Sub EnableMenus()
        Me.mnuSave.Enabled = True
        Me.mnuPrint.Enabled = True
        Me.mnuPrintPreview.Enabled = True
        Me.mnuPaper.Enabled = True
        Me.mnuWindow.Enabled = True
        Me.mnuSaveImage.Enabled = True
    End Sub
     

    Private Sub SetupNetworkToolbar()
        NetworkPanel.Controls.Clear()
        AddIconBox(IconType.Router, ToolBarTypes.Network)
        AddIconBox(IconType.L3Switch, ToolBarTypes.Network)
        AddIconBox(IconType.Firewall, ToolBarTypes.Network)
        AddIconBox(IconType.IDS, ToolBarTypes.Network)
        AddIconBox(IconType.VPN, ToolBarTypes.Network)
        AddIconBox(IconType.Switch, ToolBarTypes.Network)
        AddIconBox(IconType.Hub, ToolBarTypes.Network)
        AddIconBox(IconType.MAU, ToolBarTypes.Network)
        AddIconBox(IconType.WAP, ToolBarTypes.Network)
        AddIconBox(IconType.Custom, ToolBarTypes.Network)
        AddIconBox(IconType.Text, ToolBarTypes.Network)
    End Sub

    Private Sub SetupComputerToolbar()
        ComputerPanel.Controls.Clear()
        AddIconBox(IconType.Server, ToolBarTypes.Computer)
        AddIconBox(IconType.DBServer, ToolBarTypes.Computer)
        AddIconBox(IconType.DirServer, ToolBarTypes.Computer)
        AddIconBox(IconType.MailServer, ToolBarTypes.Computer)
        AddIconBox(IconType.WebServer, ToolBarTypes.Computer)
        AddIconBox(IconType.PC, ToolBarTypes.Computer)
        AddIconBox(IconType.Laptop, ToolBarTypes.Computer)
        AddIconBox(IconType.Tablet, ToolBarTypes.Computer)
        AddIconBox(IconType.User, ToolBarTypes.Computer)
        AddIconBox(IconType.Custom, ToolBarTypes.Computer)
        AddIconBox(IconType.Text, ToolBarTypes.Computer)
    End Sub



    Private Sub AddIconBox(ByVal Icon As IconType, ByVal Location As ToolBarTypes)

        Dim I As New PictureBox


        Select Case Icon
            Case IconType.Custom
                I = GetIconBox("Custom")
                AddHandler I.MouseDown, AddressOf CustomDrag
            Case IconType.DBServer
                I = GetIconBox("DB Server")
                AddHandler I.MouseDown, AddressOf DBDrag
            Case IconType.DirServer
                I = GetIconBox("Directory Server")
                AddHandler I.MouseDown, AddressOf DirDrag
            Case IconType.Firewall
                I = GetIconBox("Firewall")
                AddHandler I.MouseDown, AddressOf FirewallDrag
            Case IconType.Hub
                I = GetIconBox("Hub")
                AddHandler I.MouseDown, AddressOf HubDrag
            Case IconType.IDS
                I = GetIconBox("IDS")
                AddHandler I.MouseDown, AddressOf IDSDrag
            Case IconType.L3Switch
                I = GetIconBox("Layer3 Switch")
                AddHandler I.MouseDown, AddressOf L3Drag
            Case IconType.Laptop
                I = GetIconBox("Laptop")
                AddHandler I.MouseDown, AddressOf LaptopDrag
            Case IconType.MailServer
                I = GetIconBox("Mail Server")
                AddHandler I.MouseDown, AddressOf MailDrag
            Case IconType.MAU
                I = GetIconBox("MAU")
                AddHandler I.MouseDown, AddressOf MAUDrag
            Case IconType.PC
                I = GetIconBox("PC")
                AddHandler I.MouseDown, AddressOf PCDrag
            Case IconType.Router
                I = GetIconBox("Router")
                AddHandler I.MouseDown, AddressOf RouterDrag
            Case IconType.Server
                I = GetIconBox("Server")
                AddHandler I.MouseDown, AddressOf ServerDrag
            Case IconType.Switch
                I = GetIconBox("Switch")
                AddHandler I.MouseDown, AddressOf SwitchDrag
            Case IconType.Tablet
                I = GetIconBox("Tablet")
                AddHandler I.MouseDown, AddressOf TabletDrag
            Case IconType.Text
                I = GetIconBox("Text")
                AddHandler I.MouseDown, AddressOf TextDrag
            Case IconType.User
                I = GetIconBox("User")
                AddHandler I.MouseDown, AddressOf UserDrag
            Case IconType.VPN
                I = GetIconBox("VPN")
                AddHandler I.MouseDown, AddressOf VPNDrag
            Case IconType.WAP
                I = GetIconBox("WAP")
                AddHandler I.MouseDown, AddressOf WAPDrag
            Case IconType.WebServer
                I = GetIconBox("Web Server")
                AddHandler I.MouseDown, AddressOf WebDrag
        End Select


        I.Left = 0
        Select Case Location
            Case ToolBarTypes.Network
                NetworkPanel.Controls.Add(I)
                I.Top = ((NetworkPanel.Controls.Count - 1) * 24) + IconSpace * NetworkPanel.Controls.Count
            Case ToolBarTypes.Computer
                ComputerPanel.Controls.Add(I)
                I.Top = ((ComputerPanel.Controls.Count - 1) * 24) + IconSpace * ComputerPanel.Controls.Count
        End Select
        NetworkPanel.Height = NetworkPanel.Controls.Count * (24 + IconSpace)
        ComputerPanel.Height = ComputerPanel.Controls.Count * (24 + IconSpace)

    End Sub

    Private Sub Icon_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        Dim P As PictureBox = sender
        Dim Var As Integer = 5
        'If e.X > P.Width - Var Or (e.X < Var) Then
        'P.Cursor = System.Windows.Forms.Cursors.SizeWE
        'ElseIf e.Y > P.Height - Var Or (e.Y < Var) Then
        'P.Cursor = System.Windows.Forms.Cursors.SizeNS
        'Else
        P.Cursor = System.Windows.Forms.Cursors.SizeAll
        'End If
    End Sub


    Private Function GetIconBox(ByVal IconName As String) As PictureBox
        Dim Image As Bitmap = GetImageFromName(IconName)
        Dim P As New PictureBox
        P.SizeMode = PictureBoxSizeMode.StretchImage
        P.Width = 24
        P.Height = 24
        P.Image = Image
        P.Cursor = System.Windows.Forms.Cursors.SizeAll
        'P.Region = BitmapToRegion(Image, Image.GetPixel(1, 1))
        Return P
    End Function



    Private Sub RouterDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Router", DragDropEffects.Copy)
    End Sub

    Private Sub L3Drag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Layer3 Switch", DragDropEffects.Copy)
    End Sub

    Private Sub FirewallDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Firewall", DragDropEffects.Copy)
    End Sub

    Private Sub IDSDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("IDS", DragDropEffects.Copy)
    End Sub

    Private Sub SwitchDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Switch", DragDropEffects.Copy)
    End Sub

    Private Sub HubDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Hub", DragDropEffects.Copy)
    End Sub

    Private Sub MAUDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("MAU", DragDropEffects.Copy)
    End Sub

    Private Sub PCDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("PC", DragDropEffects.Copy)
    End Sub

    Private Sub ServerDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Server", DragDropEffects.Copy)
    End Sub

    Private Sub TabletDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Tablet", DragDropEffects.Copy)
    End Sub

    Private Sub TextDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Text", DragDropEffects.Copy)
    End Sub

    Private Sub VPNDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("VPN", DragDropEffects.Copy)
    End Sub

    Private Sub UserDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("User", DragDropEffects.Copy)
    End Sub

    Private Sub WAPDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("WAP", DragDropEffects.Copy)
    End Sub

    Private Sub CustomDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Custom", DragDropEffects.Copy)
    End Sub

    Private Sub DBDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("DB Server", DragDropEffects.Copy)
    End Sub

    Private Sub DirDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Directory Server", DragDropEffects.Copy)
    End Sub

    Private Sub LaptopDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Laptop", DragDropEffects.Copy)
    End Sub

    Private Sub MailDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Mail Server", DragDropEffects.Copy)
    End Sub

    Private Sub WebDrag(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs)
        sender.DoDragDrop("Web Server", DragDropEffects.Copy)
    End Sub

    Private Sub frmMain_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        For Each F As frmDrawing In Me.MdiChildren
            If F.Dirty Then
                Select Case MsgBox("Save " & F.Text & "?", MsgBoxStyle.YesNoCancel, "Save Drawing?")
                    Case MsgBoxResult.Yes
                        Me.ActivateMdiChild(F)
                        Me.SaveInk()
                        F.Close()
                    Case MsgBoxResult.No
                        F.Close()
                    Case MsgBoxResult.Cancel
                        e.Cancel = True
                        Exit For
                End Select
            End If
        Next
    End Sub



    

    


   


End Class


